package com.example.demo.Knife4j;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "⾸⻚模块")
@RestController
public class UserController {
    @Autowired(required = false)
    private JdbcTemplate jdbcTemplate;

    @ApiOperation(value = "查询所有电影数据",
            protocols = "http",
            httpMethod="GET",
            //consumes="application/json",
            //response= List.class,
            notes = "code:200 表示成功")
    @GetMapping(value="/index")
    public List<Map<String,Object>> index(){
        List<Map<String, Object>> list = jdbcTemplate
                .queryForList("select * from dianyingxinxi");
        return list;
    }

    @ResponseBody
    @PostMapping(value="/login")
    @ApiOperation(value = "登录检测", notes="根据⽤户名判断⽤户是否存在")
    public UserModel login(@RequestParam(value = "name", required = false) String account,
                           @RequestParam(value = "pass", required = false) String password)
    {
        UserModel userModel = new UserModel();
        userModel.setAccount("翟毅鑫");
        userModel.setPassword("123");
        return userModel;
    }
}